<VirtualHost *:80>
    ServerName <%= @fqdn %>
    ServerAlias <%= @fqdn %>
    Redirect / https://<%= @fqdn %>/

<% if GlobalSettings.first.site_url.downcase.include?('https://') %>
    SSLProxyEngine On
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerExpire off
<% end %>

    ProxyPass /reports/image <%= GlobalSettings.first.site_url %>/reports/image
    ProxyPassReverse /reports/image <%= GlobalSettings.first.site_url %>/reports/image
</VirtualHost>

#<!--start <%= @campaign_id %>-->
<VirtualHost *:443>
    SSLEngine On

    <% if @ssl.find_by_function("SSLCertificateFile").filename.present? %>
    SSLCertificateFile <%= @ssl.find_by_function("SSLCertificateFile").filename.file.file %>
    <% end %>
    <% if @ssl.find_by_function("SSLCertificateKeyFile").filename.present? %>
    SSLCertificateKeyFile <%= @ssl.find_by_function("SSLCertificateKeyFile").filename.file.file %>
    <% end %>
    <% if @ssl.find_by_function("SSLCertificateChainFile").filename.present? %>
    SSLCertificateChainFile <%= @ssl.find_by_function("SSLCertificateChainFile").filename.file.file %>
    <% end %>

    ServerName <%= @fqdn %>
    ServerAlias <%= @fqdn %>
    DocumentRoot <%= @template_location %>
    DirectoryIndex <%= @directory_index %>
    CustomLog     <%= @approot %>/log/www-campaign-<%= @campaign_id %>-access.log combined
    ErrorLog      <%= @approot %>/log/www-campaign-<%= @campaign_id %>-error.log

<% if @campaign_settings.directory_index == false %>
    <Directory <%= @template_location %>>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
<% end %>

<% if GlobalSettings.first.site_url.downcase.include?('https://') %>
    SSLProxyEngine On
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerExpire off
<% end %>

    ProxyPass /reports/image <%= GlobalSettings.first.site_url %>/reports/image
    ProxyPassReverse /reports/image <%= GlobalSettings.first.site_url %>/reports/image
</VirtualHost>
#<!--end <%= @campaign_id %>-->
